class Util{
    async getResourceFromUrl(url){
        try {
            const response = await fetch(url)
            const html = response.text()
            const parser = new DOMParser()
            const doc = parser.parseFromString(html,'text/html')
            const iconLink = doc.querySelector('link[rel="icon"],link[rel="shortcut icon"]')

            //new URL(iconLink.href, url) 用于防止链接为相对链接时，拼接为完整链接
            return iconLink ? (new URL(iconLink.href, url)).href : ""
        } catch (error) {
            console.log("error:",error)
            throw error;
        }
    }

    static getCssFileStyle(selectorName){//selectorName 为选择器的完整名称（包含.或#）
        // 获取所有样式表
        const styleSheets = document.styleSheets;
        // 遍历所有样式表
        for (const styleSheet of styleSheets) {
            try {
                // 遍历样式表中的所有规则
                for (const rule of styleSheet.cssRules) {
                // 检查规则的选择器是否匹配目标类
                    if (rule.selectorText === selectorName) {
                        console.log('Found class:', rule);
                        console.log('Color:', rule.style.color);
                        console.log('Font Size:', rule.style.fontSize);
                    }
                }
            } catch (e) {
                // 捕获跨域错误等异常
                console.error('Error accessing stylesheet:', e);
            }
        }
    }
}